In [2]:
import os
import os.path as op
import numpy as np
import pandas as pd
import nibabel as nib
from scipy.ndimage import binary_dilation
from skimage import morphology
import matplotlib as mpl
import matplotlib.pyplot as plt
from nipype import IdentityInterface, Node, Workflow
from nipype.interfaces.base import (BaseInterface,
BaseInterfaceInputSpec,
InputMultiPath, OutputMultiPath,
TraitedSpec, File, traits)
from nipype.interfaces import fsl, freesurfer
import seaborn as sns
from moss import locator
from moss.mosaic import Mosaic
import lyman
from lyman import tools
from lyman.tools import SaveParameters, add_suffix, nii_to_png
In [29]:
os.environ["SUBJECTS_DIR"] = '/Volumes/group/awagner/sgagnon/AP/data'
os.environ["LYMAN_DIR"] = '/Volumes/group/awagner/sgagnon/AP/scripts'
exp = 'ap_memory_raw'
altmodel = 'byshockCond'
subjects = '/Volumes/group/awagner/sgagnon/AP/scripts/subjects_shock_byshockCondSH.txt'
basedir = '/Volumes/group/awagner/sgagnon/AP/analysis/ap_memory_raw-byshockCond/group_stress/safe-threat_sourcehit-cr'
project = lyman.gather_project_info()
exp_info = lyman.gather_experiment_info(exp, altmodel)
subject_list = lyman.determine_subjects([subjects])
subj_source = Node(IdentityInterface(fields=["subject_id"]),
name="subj_source")
subj_source.inputs.subject_id = subject_list
for contrast_num in [1, 2]:
# Estimate smoothness
smoothest = fsl.SmoothEstimate()
smoothest.inputs.mask_file = basedir + '/stats+/mask.nii.gz'
smoothest.inputs.zstat_file = basedir + '/stats+/zstat'+str(contrast_num)+'.nii.gz'
smooth = smoothest.run()
# Cluster correct
cluster = fsl.Cluster(in_file=smoothest.inputs.zstat_file,
threshold=exp_info["cluster_zthresh"],
pthreshold=exp_info["grf_pthresh"],
out_threshold_file=basedir+'/zstat'+str(contrast_num)+'_threshold.nii.gz',
out_index_file=basedir+'/zstat'+str(contrast_num)+'_index.nii.gz',
out_localmax_txt_file=basedir+'/zstat'+str(contrast_num)+'_localmax.txt',
peak_distance=exp_info["peak_distance"],
use_mm=True,
dlh=smooth.outputs.dlh,
volume=smooth.outputs.volume)
cluster.run()
In [5]:
os.environ["SUBJECTS_DIR"] = '/Volumes/group/awagner/sgagnon/SST/data'
os.environ["LYMAN_DIR"] = '/Volumes/group/awagner/sgagnon/SST/scripts'
exp = 'mvpa'
altmodel = 'goodruntype_filt'
subjects = '/Volumes/group/awagner/sgagnon/SST/scripts/subjects_control.txt'
basedir = '/Volumes/group/awagner/sgagnon/SST/analysis/mvpa-goodruntype_filt/group_control/probe-habit'
project = lyman.gather_project_info()
exp_info = lyman.gather_experiment_info(exp, altmodel)
subject_list = lyman.determine_subjects([subjects])
subj_source = Node(IdentityInterface(fields=["subject_id"]),
name="subj_source")
subj_source.inputs.subject_id = subject_list
for contrast_num in [1, 2]:
# Estimate smoothness
smoothest = fsl.SmoothEstimate()
smoothest.inputs.mask_file = basedir + '/stats/mask.nii.gz'
smoothest.inputs.zstat_file = basedir + '/stats/zstat'+str(contrast_num)+'.nii.gz'
smooth = smoothest.run()
# Cluster correct
cluster = fsl.Cluster(in_file=smoothest.inputs.zstat_file,
threshold=exp_info["cluster_zthresh"],
pthreshold=exp_info["grf_pthresh"],
out_threshold_file=basedir+'/zstat'+str(contrast_num)+'_threshold.nii.gz',
out_index_file=basedir+'/zstat'+str(contrast_num)+'_index.nii.gz',
out_localmax_txt_file=basedir+'/zstat'+str(contrast_num)+'_localmax.txt',
peak_distance=exp_info["peak_distance"],
use_mm=True,
dlh=smooth.outputs.dlh,
volume=smooth.outputs.volume)
cluster.run()
In [7]:
os.environ["SUBJECTS_DIR"] = '/Volumes/group/awagner/sgagnon/SST/data'
os.environ["LYMAN_DIR"] = '/Volumes/group/awagner/sgagnon/SST/scripts'
exp = 'mvpa'
altmodel = 'goodruntype_filt'
subjects = '/Volumes/group/awagner/sgagnon/SST/scripts/subjects_control.txt'
basedir = '/Volumes/group/awagner/sgagnon/SST/analysis/mvpa-goodruntype_filt/group_control/nav_probe-habit'
project = lyman.gather_project_info()
exp_info = lyman.gather_experiment_info(exp, altmodel)
subject_list = lyman.determine_subjects([subjects])
subj_source = Node(IdentityInterface(fields=["subject_id"]),
name="subj_source")
subj_source.inputs.subject_id = subject_list
for contrast_num in [1, 2]:
# Estimate smoothness
smoothest = fsl.SmoothEstimate()
smoothest.inputs.mask_file = basedir + '/stats/mask.nii.gz'
smoothest.inputs.zstat_file = basedir + '/stats/zstat'+str(contrast_num)+'.nii.gz'
smooth = smoothest.run()
# Cluster correct
cluster = fsl.Cluster(in_file=smoothest.inputs.zstat_file,
threshold=exp_info["cluster_zthresh"],
pthreshold=exp_info["grf_pthresh"],
out_threshold_file=basedir+'/zstat'+str(contrast_num)+'_threshold.nii.gz',
out_index_file=basedir+'/zstat'+str(contrast_num)+'_index.nii.gz',
out_localmax_txt_file=basedir+'/zstat'+str(contrast_num)+'_localmax.txt',
peak_distance=exp_info["peak_distance"],
use_mm=True,
dlh=smooth.outputs.dlh,
volume=smooth.outputs.volume)
cluster.run()
In [9]:
os.environ["SUBJECTS_DIR"] = '/Volumes/group/awagner/sgagnon/SST/data'
os.environ["LYMAN_DIR"] = '/Volumes/group/awagner/sgagnon/SST/scripts'
exp = 'mvpa'
altmodel = 'goodruntype_filt'
subjects = '/Volumes/group/awagner/sgagnon/SST/scripts/subjects_stress.txt'
basedir = '/Volumes/group/awagner/sgagnon/SST/analysis/mvpa-goodruntype_filt/group_stress/probe-habit'
project = lyman.gather_project_info()
exp_info = lyman.gather_experiment_info(exp, altmodel)
subject_list = lyman.determine_subjects([subjects])
subj_source = Node(IdentityInterface(fields=["subject_id"]),
name="subj_source")
subj_source.inputs.subject_id = subject_list
for contrast_num in [1, 2]:
# Estimate smoothness
smoothest = fsl.SmoothEstimate()
smoothest.inputs.mask_file = basedir + '/stats/mask.nii.gz'
smoothest.inputs.zstat_file = basedir + '/stats/zstat'+str(contrast_num)+'.nii.gz'
smooth = smoothest.run()
# Cluster correct
cluster = fsl.Cluster(in_file=smoothest.inputs.zstat_file,
threshold=exp_info["cluster_zthresh"],
pthreshold=exp_info["grf_pthresh"],
out_threshold_file=basedir+'/zstat'+str(contrast_num)+'_threshold.nii.gz',
out_index_file=basedir+'/zstat'+str(contrast_num)+'_index.nii.gz',
out_localmax_txt_file=basedir+'/zstat'+str(contrast_num)+'_localmax.txt',
peak_distance=exp_info["peak_distance"],
use_mm=True,
dlh=smooth.outputs.dlh,
volume=smooth.outputs.volume)
cluster.run()
In [8]:
os.environ["SUBJECTS_DIR"] = '/Volumes/group/awagner/sgagnon/SST/data'
os.environ["LYMAN_DIR"] = '/Volumes/group/awagner/sgagnon/SST/scripts'
exp = 'mvpa'
altmodel = 'goodruntype_filt'
subjects = '/Volumes/group/awagner/sgagnon/SST/scripts/subjects_stress.txt'
basedir = '/Volumes/group/awagner/sgagnon/SST/analysis/mvpa-goodruntype_filt/group_stress/nav_probe-habit'
project = lyman.gather_project_info()
exp_info = lyman.gather_experiment_info(exp, altmodel)
subject_list = lyman.determine_subjects([subjects])
subj_source = Node(IdentityInterface(fields=["subject_id"]),
name="subj_source")
subj_source.inputs.subject_id = subject_list
for contrast_num in [1, 2]:
# Estimate smoothness
smoothest = fsl.SmoothEstimate()
smoothest.inputs.mask_file = basedir + '/stats/mask.nii.gz'
smoothest.inputs.zstat_file = basedir + '/stats/zstat'+str(contrast_num)+'.nii.gz'
smooth = smoothest.run()
# Cluster correct
cluster = fsl.Cluster(in_file=smoothest.inputs.zstat_file,
threshold=exp_info["cluster_zthresh"],
pthreshold=exp_info["grf_pthresh"],
out_threshold_file=basedir+'/zstat'+str(contrast_num)+'_threshold.nii.gz',
out_index_file=basedir+'/zstat'+str(contrast_num)+'_index.nii.gz',
out_localmax_txt_file=basedir+'/zstat'+str(contrast_num)+'_localmax.txt',
peak_distance=exp_info["peak_distance"],
use_mm=True,
dlh=smooth.outputs.dlh,
volume=smooth.outputs.volume)
cluster.run()
In [ ]:
In [12]:
os.environ["SUBJECTS_DIR"] = '/Volumes/group/awagner/sgagnon/SST/data'
os.environ["LYMAN_DIR"] = '/Volumes/group/awagner/sgagnon/SST/scripts'
exp = 'mvpa'
altmodel = 'goodruntype_filt'
subjects = '/Volumes/group/awagner/sgagnon/SST/scripts/subjects.txt'
basedir = '/Volumes/group/awagner/sgagnon/SST/analysis/mvpa-goodruntype_filt/group/probe-habit_control-stress'
project = lyman.gather_project_info()
exp_info = lyman.gather_experiment_info(exp, altmodel)
subject_list = lyman.determine_subjects([subjects])
subj_source = Node(IdentityInterface(fields=["subject_id"]),
name="subj_source")
subj_source.inputs.subject_id = subject_list
for contrast_num in [1, 2]:
# Estimate smoothness
smoothest = fsl.SmoothEstimate()
smoothest.inputs.mask_file = basedir + '/stats/mask.nii.gz'
smoothest.inputs.zstat_file = basedir + '/stats/zstat'+str(contrast_num)+'.nii.gz'
smooth = smoothest.run()
# Cluster correct
cluster = fsl.Cluster(in_file=smoothest.inputs.zstat_file,
threshold=exp_info["cluster_zthresh"],
pthreshold=exp_info["grf_pthresh"],
out_threshold_file=basedir+'/zstat'+str(contrast_num)+'_threshold.nii.gz',
out_index_file=basedir+'/zstat'+str(contrast_num)+'_index.nii.gz',
out_localmax_txt_file=basedir+'/zstat'+str(contrast_num)+'_localmax.txt',
peak_distance=exp_info["peak_distance"],
use_mm=True,
dlh=smooth.outputs.dlh,
volume=smooth.outputs.volume)
cluster.run()
In [14]:
os.environ["SUBJECTS_DIR"] = '/Volumes/group/awagner/sgagnon/SST/data'
os.environ["LYMAN_DIR"] = '/Volumes/group/awagner/sgagnon/SST/scripts'
exp = 'mvpa'
altmodel = 'goodruntype_filt'
subjects = '/Volumes/group/awagner/sgagnon/SST/scripts/subjects.txt'
basedir = '/Volumes/group/awagner/sgagnon/SST/analysis/mvpa-goodruntype_filt/group/probe-habit_control-stress_mumford'
project = lyman.gather_project_info()
exp_info = lyman.gather_experiment_info(exp, altmodel)
subject_list = lyman.determine_subjects([subjects])
subj_source = Node(IdentityInterface(fields=["subject_id"]),
name="subj_source")
subj_source.inputs.subject_id = subject_list
for contrast_num in [1, 2, 3]:
# Estimate smoothness
smoothest = fsl.SmoothEstimate()
smoothest.inputs.mask_file = basedir + '/stats/mask.nii.gz'
smoothest.inputs.zstat_file = basedir + '/stats/zstat'+str(contrast_num)+'.nii.gz'
smooth = smoothest.run()
# Cluster correct
cluster = fsl.Cluster(in_file=smoothest.inputs.zstat_file,
threshold=exp_info["cluster_zthresh"],
pthreshold=exp_info["grf_pthresh"],
out_threshold_file=basedir+'/zstat'+str(contrast_num)+'_threshold.nii.gz',
out_index_file=basedir+'/zstat'+str(contrast_num)+'_index.nii.gz',
out_localmax_txt_file=basedir+'/zstat'+str(contrast_num)+'_localmax.txt',
peak_distance=exp_info["peak_distance"],
use_mm=True,
dlh=smooth.outputs.dlh,
volume=smooth.outputs.volume)
cluster.run()
In [16]:
os.environ["SUBJECTS_DIR"] = '/Volumes/group/awagner/sgagnon/SST/data'
os.environ["LYMAN_DIR"] = '/Volumes/group/awagner/sgagnon/SST/scripts'
exp = 'mvpa'
altmodel = 'goodruntype_filt'
subjects = '/Volumes/group/awagner/sgagnon/SST/scripts/subjects.txt'
basedir = '/Volumes/group/awagner/sgagnon/SST/analysis/mvpa-goodruntype_filt/group/probe-habit_control-stress_mumford_restrictedROI'
project = lyman.gather_project_info()
exp_info = lyman.gather_experiment_info(exp, altmodel)
subject_list = lyman.determine_subjects([subjects])
subj_source = Node(IdentityInterface(fields=["subject_id"]),
name="subj_source")
subj_source.inputs.subject_id = subject_list
for contrast_num in [1, 2, 3]:
# Estimate smoothness
smoothest = fsl.SmoothEstimate()
smoothest.inputs.mask_file = basedir + '/stats/mask.nii.gz'
smoothest.inputs.zstat_file = basedir + '/stats/zstat'+str(contrast_num)+'.nii.gz'
smooth = smoothest.run()
# Cluster correct
cluster = fsl.Cluster(in_file=smoothest.inputs.zstat_file,
threshold=exp_info["cluster_zthresh"],
pthreshold=exp_info["grf_pthresh"],
out_threshold_file=basedir+'/zstat'+str(contrast_num)+'_threshold.nii.gz',
out_index_file=basedir+'/zstat'+str(contrast_num)+'_index.nii.gz',
out_localmax_txt_file=basedir+'/zstat'+str(contrast_num)+'_localmax.txt',
use_mm=True,
dlh=smooth.outputs.dlh,
volume=smooth.outputs.volume)
cluster.run()
In [17]:
os.environ["SUBJECTS_DIR"] = '/Volumes/group/awagner/sgagnon/SST/data'
os.environ["LYMAN_DIR"] = '/Volumes/group/awagner/sgagnon/SST/scripts'
exp = 'mvpa'
altmodel = 'goodruntype_filt'
subjects = '/Volumes/group/awagner/sgagnon/SST/scripts/subjects.txt'
basedir = '/Volumes/group/awagner/sgagnon/SST/analysis/mvpa-goodruntype_filt/group/probe1v2_control-stress_mumford'
project = lyman.gather_project_info()
exp_info = lyman.gather_experiment_info(exp, altmodel)
subject_list = lyman.determine_subjects([subjects])
subj_source = Node(IdentityInterface(fields=["subject_id"]),
name="subj_source")
subj_source.inputs.subject_id = subject_list
for contrast_num in [1, 2, 3]:
# Estimate smoothness
smoothest = fsl.SmoothEstimate()
smoothest.inputs.mask_file = basedir + '/stats/mask.nii.gz'
smoothest.inputs.zstat_file = basedir + '/stats/zstat'+str(contrast_num)+'.nii.gz'
smooth = smoothest.run()
# Cluster correct
cluster = fsl.Cluster(in_file=smoothest.inputs.zstat_file,
threshold=exp_info["cluster_zthresh"],
pthreshold=exp_info["grf_pthresh"],
out_threshold_file=basedir+'/zstat'+str(contrast_num)+'_threshold.nii.gz',
out_index_file=basedir+'/zstat'+str(contrast_num)+'_index.nii.gz',
out_localmax_txt_file=basedir+'/zstat'+str(contrast_num)+'_localmax.txt',
use_mm=True,
dlh=smooth.outputs.dlh,
volume=smooth.outputs.volume)
cluster.run()
In [ ]: